﻿package frEngine.shader.filters.fragmentFilters
{
    import __AS3__.vec.*;
    import baseEngine.core.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.registType.*;

    public class JXmohuFilter extends FilterBase
    {
        private const step:Number = 7;
        private const stepLen:Number = 0.01;
        public var blurConst:Vector.<Number>;

        public function JXmohuFilter()
        {
            this.blurConst = this.Vector.<Number>([0.05, 0.5, 1 - this.stepLen, this.step]);
            super(FilterType.JXmohu, FilterPriority.JXmohuFilter);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{blurConst}", false).value = this.blurConst;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "JXmohuFilter0";
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_5:Array = null;
            var _loc_6:String = null;
            var _loc_7:FsParam = null;
            var _loc_8:Texture3D = null;
            var _loc_9:String = null;
            var _loc_10:String = null;
            var _loc_11:String = null;
            var _loc_12:int = 0;
            var _loc_3:String = "";
            var _loc_4:* = param1.getParamByName(FilterName.F_UVPostion, false);
            if (_loc_4)
            {
                _loc_5 = new Array();
                _loc_5.push(new ToBuilderInfo("fc0", "{blurConst}", false, 1, this.blurConst));
                _loc_6 = "sub ft0 {F_UVPostion} fc0.y\n" + "mul ft1.xy ft0.xy ft0.xy\n" + "add ft1.x ft1.x ft1.y\n" + "mul ft1.x ft1.x fc0.x\n" + "sub ft1.x {fcConst1}.z ft1.x\n";
                _loc_7 = param1.getParamByName("{texture1}", false);
                _loc_8 = _loc_7.value;
                _loc_9 = getSmapleString("{texture1}", _loc_8.format, param2, _loc_8.mipMode);
                _loc_10 = "mul ft0.xy ft0.xy ft1.x\n" + "add ft2 ft0 fc0.y\n" + "tex ft2 ft2 " + _loc_9 + "\n" + "add {output} {output} ft2\n";
                _loc_11 = "div {output} {output} fc0.w\n";
                _loc_3 = _loc_6;
                _loc_12 = 1;
                while (_loc_12 < this.step)
                {
                    
                    _loc_3 = _loc_3 + _loc_10;
                    _loc_12++;
                }
                _loc_3 = _loc_3 + _loc_11;
                _loc_3 = param1.toBuild(_loc_3, _loc_5);
            }
            return _loc_3;
        }// end function

    }
}
